Webpack运行(在某种程度上)。完成运行。许多网上人已经解释了一个错误(见下文)。
UplifyJs中的koLabs.js中的错误 SyntaxError:意外令牌:punc())[./~/source-map-loader!./ Labs / labsCtrl.js:512,0]
但是,它只缩小主要位于顶部文件夹中的选定js文件。它将文件保留在子文件夹中而没有任何缩小。
/ Scripts / Tomat0-起作用 / Scripts / Tomat0 /(子文件夹)-不会缩小
对此有任何想法。
我的Webpack:
const webpack = require('webpack');
const path = require('path');
const merge = require("webpack-merge");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const WebpackAutoInject = require('webpack-auto-inject-version');
var CopyWebpackPlugin = require('copy-webpack-plugin');
//const TARGET = process.env.npm_lifecycle_event;
const PATHS =
{
scripts: path.join(__dirname, 'Scripts'),
mobile: path.join(__dirname, "mobile/js"),
Tomat0: path.join(__dirname, 'Scripts/Tomat0')
};
//console.log(__dirname);
//console.log(PATHS.scripts);
module.exports =
{
//context: path.resolve(__dirname, './Scripts/Tomat0/Account'),
noInfo: false,
debug: true,
devtool: 'source-map',
entry:
{
vendorReact:
[
// path.resolve("./mobile/css/Tomat0-css.js"),
//"react", "react-dom",
"jquery", "jQuery-ui",
"inputmask",
"bootstrap", "moment", "moment/locale/es", "moment/locale/pt",
"knockout", "knockout.mapping", "sammy"
//,path.resolve("./Scripts/jquery-ui.min.js")
,path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
, path.resolve("./Scripts/jquery.scrollTo.min.js")
],
// vendorKO:
// [
// "jquery", "bootstrap", "moment",
// "knockout", "knockout.mapping", "sammy"
// ,path.resolve("./Scripts/jquery.fittext-1.1.min.js")
// ,path.resolve("./Scripts/jquery-ui.min.js")
// ,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
// ,path.resolve("./Scripts/jquery.scrollTo.min.js")
// ],
login:
[
// "react", "react-dom",
"bootstrap", "moment", "jQuery-ui"
,"moment/locale/es", "moment/locale/pt"
//path.resolve("./mobile/css/Tomat0-css.js"),
,"jsbridge"
//,path.resolve('./Scripts/javascriptBridge.js')
//,path.resolve("./Scripts/jquery-ui.min.js")
,path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/jtsage-datebox.bootstrap.min.js")
,path.resolve("./Scripts/jtsage-datebox.i18n.es-ES.utf8.min.js")
,path.resolve("./Scripts/jtsage-datebox.i18n.pt-BR.utf8.min.js")
// ,'commonControls.js'
// ,'accountCreateReact.js'
// ,'personalInfoReact.js'
// ,'loginReact.js'
,path.resolve('./Account/commonControls.tsx')
,path.resolve('./Account/accountCreateReact.tsx')
,path.resolve('./Account/personalInfoReact.tsx')
,path.resolve('./Account/loginReact.tsx')
],
account:
[
// "react", "react-dom",
"bootstrap", "moment", "jQuery-ui",
"moment/locale/es", "moment/locale/pt",
//"jsbridge",
//path.resolve("./mobile/css/Tomat0-css.js"),
//path.resolve("./Scripts/maskedinput-1.4.js"),
// path.resolve("./Scripts/jquery-ui.min.js")
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/jtsage-datebox.bootstrap.min.js")
,path.resolve("./Scripts/jtsage-datebox.i18n.es-ES.utf8.min.js")
,path.resolve("./Scripts/jtsage-datebox.i18n.pt-BR.utf8.min.js")
//,path.resolve("./Scripts/bootstrap-datepicker.min.js")
//,path.resolve("./Scripts/bootstrap-datepicker.es.min.js")
//,path.resolve('./Scripts/javascriptBridge.js')
//, path.resolve("./Scripts/masked_input_1.4.js")
,path.resolve('./Account/commonControls.tsx')
,path.resolve('./Account/accountCreateReact.tsx')
,path.resolve('./Account/personalInfoReact.tsx')
,path.resolve('./Account/dforReact.tsx')
,path.resolve('./Account/surranReact.tsx')
,path.resolve('./Account/associations.tsx')
,path.resolve('./Account/permissions.tsx')
,path.resolve('./Account/invitation.tsx')
,path.resolve('./Account/notes.tsx')
, path.resolve('./Account/seneg.tsx')
, path.resolve('./Account/AddGN.tsx')
,path.resolve('./Account/account.tsx')
,path.resolve('./Account/MHT.tsx')
,path.resolve('./Account/minders.tsx')
// ,'commonControls.js'
// ,'accountCreateReact.js'
// ,'personalInfoReact.js'
// ,"dforReact.js"
// ,"surranReact.js"
// ,"associations.js"
// ,"permissions.js"
// ,"invitation.js"
// ,"notes.js"
// ,"account.js"
// ,"MHT.js"
],
komds:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
//"jquery",
//path.resolve("./Scripts/jquery-ui.min.js"),
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
//,path.resolve("./sbal/sbalCtrl.js")
,path.resolve("./mds/mdsCtrl.js")
],
kosbal:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
,path.resolve("./sbal/sbalCtrl.js")
],
koAsh:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
,path.resolve("./Ash/AshModel.ts")
,path.resolve("./Ash/AshCtrl.ts")
// ,path.resolve("./Scripts/Tomat0/Ash/AshModel.js")
// ,path.resolve("./Scripts/Tomat0/Ash/AshCtrl.js")
],
kosol:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
,path.resolve("./sol/solModel.ts")
,path.resolve("./sol/solCtrl.ts")
// ,path.resolve("./Scripts/Tomat0/sol/solModel.js")
// ,path.resolve("./Scripts/Tomat0/sol/solCtrl.js")
],
kovacat:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
,path.resolve("./vacat/vacatModel.ts")
,path.resolve("./vacat/vacatCtrl.ts")
// ,path.resolve("./Scripts/Tomat0/Vacctnes/vacatModel.js")
// ,path.resolve("./Scripts/Tomat0/vacat/vacatCtrl.js")
],
koVitals:
[
"bootstrap", "moment", //"knockout", "knockout.mapping", "sammy",
"moment/locale/es", "moment/locale/pt",
path.resolve("./Scripts/jquery.fittext-1.1.min.js")
,path.resolve("./Scripts/jquery.scrollTo.min.js")
,path.resolve("./mobile/js/mobiscroll-2.3.1.custom.min.js")
,path.resolve("./Scripts/Tomat0/Account/_partialLoginPopup.js")
,path.resolve("./Vitals/vitalsModel.ts")
,path.resolve("./Vitals/vitalsCtrl.ts")
// ,path.resolve("./Scripts/Tomat0/Vitals/vitalsModel.js")
// ,path.resolve("./Scripts/Tomat0/Vitals/vitalsCtrl.js")
]
},
output:
{
path: PATHS.Tomat0,
filename: '[name].js'
,libraryTarget: 'var'
},
externals:
{
'react':
{
"var": 'React',
web: 'React',
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'React'
},
'react-dom':
{
"var": 'ReactDOM',
web: 'ReactDOM',
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'ReactDOM'
}
},
plugins:
[
new webpack.ProvidePlugin
({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
}),
// new webpack.ProvidePlugin
// ({
// Bootstrap: "bootstrap",
// bootstrap: "bootstrap",
// }),
// new webpack.ProvidePlugin
// ({
// moment: "moment",
// }),
// new webpack.ProvidePlugin
// ({
// React: "react",
// react: "react",
// "window.react": "react",
// "window.React": "react"
// }),
// new webpack.ProvidePlugin
// ({
// ReactDOM: "react-dom",
// "react-dom": "react-dom",
// "window.ReactDOM": "react-dom"
// }),
new webpack.ProvidePlugin
({
knockout: "knockout",
ko: "knockout",
}),
new webpack.ProvidePlugin
({
"knockout.mapping": "knockout.mapping",
"ko.mapping": "knockout.mapping",
}),
new webpack.ProvidePlugin
({
Sammy: "sammy",
sammy: "sammy",
}),
new webpack.ProvidePlugin // This works
({
typeahead: "corejs-typeahead",
bloodhound: "corejs-typeahead",
Bloodhound: "corejs-typeahead",
}),
new webpack.ProvidePlugin
({
jsbridge: "javascriptBridge"
}),
new webpack.ProvidePlugin
({
inputmask: "inputmask"
}),
// DO NOT USE THESE - This version no longer works.
// new webpack.ProvidePlugin
// ({
// typeahead: path.resolve('./Scripts/typeahead.bundle.js'),
// Bloodhound: path.resolve('./Scripts/typeahead.bundle.js'),
// }),
// NOTE: to augment the version, use switches --evn.major, env.minor, or --env.patch
new WebpackAutoInject
({
PACKAGE_JSON_PATH: './package.json',
components:
{
InjectAsComment: true
},
componentsOptions:
{
InjectAsComment:
{
tag: 'Build version: {version} - {date}' // default
}
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendorReact", /* filename= */"vendorReact.js", Infinity),
// DO NOT USE Multiple Plugins - does not yield correct results.
// new webpack.optimize.CommonsChunkPlugin
// (
// {
// names: ["vendorReact", "vendorKO"], filename: "[name].js", minChunks: Infinity
// }
// ),
// This is needed to prevent moment js from loading ALL locales - we only support three for now (en|es|pt)
new webpack.ContextReplacementPlugin(/moment[\\\/]locale$/, /^\.\/es$/, /^\.\/pt$/),
// Add a plug-in for straight copy of files from node_modules to Scripts directory for publishing from VS
new CopyWebpackPlugin
(
[
{from: './node_modules/react/dist/*.js', to: path.join(PATHS.scripts, 'react'), flatten: true},
{from: './node_modules/react-dom/dist/*.js', to: path.join(PATHS.scripts, 'react'), flatten: true},
]
),
// new webpack.DefinePlugin(
// {
// 'process.env':
// {
// NODE_ENV: JSON.stringify('production')
// }
// }),
// new ExtractTextPlugin
// ({
// filename: "[name].css"
// }),
new webpack.optimize.UglifyJsPlugin(
{
// compress:
// {
// warnings: false,
// },
minimize: true,
output:
{
comments: false,
},
})
],
// noParse:
// [
// ///[\/\\]node_modules[\/\\]fittext[\/\\]dist[\/\\]jquery\.fittext\.js$/,
// path.join(PATHS.scripts, "typeahead.bundle.js")
// ],
resolve:
{
extensions: ['', '.js', '.json', '.ts', 'tsx', 'css'],
root:
[
path.resolve('.'),
path.resolve('./Scripts'),
path.resolve('./Scripts/Tomat0/Account')
],
alias:
{
i18nextXHRBackend: "i18next-xhr-backend/i18nextXHRBackend.js",
jsbridge: path.join(PATHS.scripts, "javascriptBridge.js"),
inputmask: path.join(PATHS.scripts, "maskedinput-1.4.js"),
//"jquery-ui": "jquery-ui/jquery-ui.js",
// Bloodhound: path.resolve('./Scripts/Bloodhound.js'),
// typeahead: path.resolve('./Scripts/typeahead.bundle.js'),
// ko: "knockout/build/output/knockout-latest.js",
// "ko.mapping": "knockout.mapping/knockout.mapping.js",
// Sammy: "sammy/lib/sammy.js",
}
},
// modulesDirectories:
// [
// 'node_modules',
// 'Scripts'
// ],
module:
{
loaders:
[
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
//{test: /\.(ts|tsx)?$/, loader: "ts-loader"},
{test: /\.(ts|tsx)?$/, loader: "awesome-typescript-loader"},
{test: /\.json$/, loader: "json-loader" },
{test: /\.html$/, loader: 'html' },
{test: /\.png$/, loader: "file-loader" },
// {test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
{test: /\.(woff|woff2)$/, loader:"url?prefix=font/&limit=5000"},
{test: /\.ttf$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{test: /\.eot$/, loader: "file" },
{test: /\.svg$/, loader: "url?limit=10000&mimetype=image/svg+xml" },
// Does not work.
// {
// test: require.resolve('jquery'),
// loader: 'expose-loader?jQuery!expose-loader?$'
// },
],
preLoaders:
[
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
test: /\.js$/,
loader: "source-map-loader"
}
]
}
}