반응형
파일을 ugliate하여 다른 장소에 저장하는 방법(vue.http)
어떻게 해야 할지 모르겠어요.server.js
파일에 저장하다dist
아래 폴더server
폴더입니다.지금은 그냥...CopyWebpackPlugin
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
},
{
from: path.resolve(__dirname, '../src/server'),
to: config.build.assetsServerDirectory,
ignore: ['*.sql']
}
]),
이것은 동작하지만, 단순한 카피 앤 페이스트에 지나지 않습니다.
우글라이프 + copy-webpack-module's 를 사용할 수 있습니다.
패키지를 인스톨 합니다.
npm install uglify-es --save-dev
소스에 추가합니다.
const UglifyJS = require("uglify-es"); // add the require new CopyWebpackPlugin([ { from: path.resolve(__dirname, '../static'), to: config.build.assetsSubDirectory, ignore: ['.*'] }, { from: path.resolve(__dirname, '../src/server'), to: config.build.assetsServerDirectory, transform: function (content, path) { // add transform() return UglifyJS.minify(content.toString()).code; // use uglify }, // (no args = mangle+compress) ignore: ['*.sql'] } ]),
주의:UglifyJS.minify(content.toString()).code
와 같다UglifyJS.minify(content.toString('utf8')).code
. 인코딩이 다른 경우 옵션이 있습니다.
그것을 위한 도서관은 이미 준비되어 있습니다.uglifyjs-webpack-plugin을 사용할 수 있습니다.
그런 다음 번들파일을 원하는 디렉토리에 출력합니다.
플러그인 사용을 좋아하지 않는 경우.웹 팩의 기본 uglier를 사용할 수 있습니다.
const webpack = require("webpack");
module.exports = {
entry: {
"bundle": "./server/server.js",
}
output: {
path: "./dist",
filename: "[name].js"
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
include: /\.js$/,
minimize: true
})
]
};
언급URL : https://stackoverflow.com/questions/49786079/how-to-uglify-a-file-and-save-to-another-location-vue-js
반응형
'programing' 카테고리의 다른 글
.vue 파일에서 여러 개체를 내보내는 방법 (0) | 2022.08.02 |
---|---|
Vuex 저장소 상태가 정의되지 않았습니다. (0) | 2022.08.01 |
MinGW의 "Unknown type name 'uint8_t' 메시지 (0) | 2022.08.01 |
vue 구성 요소에서 vuex에서 필터링된 데이터가 반응하지 않음 (0) | 2022.08.01 |
VueJ를 사용한 체크박스 필터링s (0) | 2022.08.01 |